package nc.ui.arap.config.ref;

import nc.bs.sec.esapi.NCESAPI;
import nc.vo.pubapp.pattern.pub.SqlBuilder;
import nccloud.commons.lang.StringUtils;

public class SuppLinkMainRefModel extends nc.ui.bd.ref.model.SupplierLinkManRefModel {

	private String pk_supplier;

	@Override
	public void reset() {
		super.reset();
		setOrderPart("email asc");
	}

	@Override
	public String getWherePart() {
		SqlBuilder sql = new SqlBuilder();
		if (StringUtils.isBlank(pk_supplier)) {
			sql.append("pk_supplier", "#emptyvalue");
		} else {
			sql.append("pk_supplier", NCESAPI.clientSqlEncode(pk_supplier));
		}
		return sql.toString();
	}

	public Object getValue(String field) {
		Object[] values = getValues(field);

		Object value = null;
		String strValue = "";
		if (values != null && values.length > 1) {
			for (Object pkobj : values) {
				strValue += pkobj + ",";
			}
			strValue = strValue.substring(0, strValue.lastIndexOf(","));
			value = strValue;
		} else if (values != null && values.length > 0) {
			value = values[0];
		}

		return value;
	}

	public void setPk_supplier(String pk_supplier) {
		this.pk_supplier = pk_supplier;
	}

}
